using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FlatRedBall;
using FlatRedBall.Graphics;
using FlatRedBall.ManagedSpriteGroups;
using FlatRedBall.Math;
using FlatRedBall.Math.Geometry;
using FlatRedBall.AI.Pathfinding;
using FlatRedBall.Graphics.Animation;
using FlatRedBall.Input;
using FlatRedBall.Graphics.Particle;
using FlatRedBall.Instructions;
using FlatRedBall.Math.Splines;


// Generated Usings
using WinRos_Xna.Screens;
using WinRos_Xna.Entities;


#if FRB_XNA || SILVERLIGHT
using Keys = Microsoft.Xna.Framework.Input.Keys;
using Vector3 = Microsoft.Xna.Framework.Vector3;
using Texture2D = Microsoft.Xna.Framework.Graphics.Texture2D;
#endif

namespace WinRos_Xna.Entities
{
	public partial class TextBox : PositionedObject
	{
        // This is made global so that static lazy-loaded content can access it.
        public static string ContentManagerName
        {
            get;
            set;
        }

		// Generated Fields
		static Scene TextScene;

		private Sprite textInstance;


        public TextBox(string contentManagerName) :
            this(contentManagerName, true)
        {
        }


        public TextBox(string contentManagerName, bool addToManagers) :
			base()
		{
			// Don't delete this:
            ContentManagerName = contentManagerName;
            Initialize(addToManagers);

		}

		protected virtual void Initialize(bool addToManagers)
		{
			// Generated Initialize
			LoadStaticContent(ContentManagerName);

			textInstance = TextScene.Sprites.FindByName("textbox1").Clone();

			if(addToManagers)
			{
				AddToManagers(null);
			}


		}

// Generated AddToManagers

        public virtual void AddToManagers(Layer layerToAddTo)
        {
			SpriteManager.AddPositionedObject(this);
			SpriteManager.AddToLayer(textInstance, layerToAddTo);
			textInstance.AttachTo(this, true);


			CustomInitialize();

        }

		public virtual void Activity()
		{
			// Generated Activity




			CustomActivity();
		}

		public virtual void Destroy()
		{
			// Generated Destroy
			SpriteManager.RemovePositionedObject(this);


			SpriteManager.RemoveSprite(textInstance);



			CustomDestroy();
		}

		// Generated Methods
		public static void LoadStaticContent(string contentManagerName)
		{
			ContentManagerName = contentManagerName;
			bool registerUnload = false;
			if(!FlatRedBallServices.IsLoaded("Content/Entities/TextBox/TextScene.scnx", ContentManagerName))
			{
				registerUnload = true;
				TextScene = FlatRedBallServices.Load<Scene>("Content/Entities/TextBox/TextScene.scnx", ContentManagerName);
				FlatRedBallServices.AddNonDisposable("Content/Entities/TextBox/TextScene.scnx", TextScene, ContentManagerName);
			}
			else
			{
				TextScene = (Scene)FlatRedBallServices.GetNonDisposable("Content/Entities/TextBox/TextScene.scnx", ContentManagerName);
			}

			const bool throwExceptionIfAfterInitialize = false;
			if(throwExceptionIfAfterInitialize && registerUnload && ScreenManager.CurrentScreen != null && ScreenManager.CurrentScreen.ActivityCallCount > 0 && !ScreenManager.CurrentScreen.IsActivityFinished)
			{
				throw new InvalidOperationException("Content is being loaded after the current Screen is initialized.  This exception is being thrown because of a setting in Glue.");
			}
			if(registerUnload)
			{
				FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("TextBoxStaticUnload", UnloadStaticContent);
			}
			CustomLoadStaticContent(contentManagerName);
		}
		public static void UnloadStaticContent()
		{
			if(TextScene != null)
			{
			}
		}

    }
}
